﻿@model WishlistModel
@using Nop.Core.Domain.Orders;
@using Nop.Web.Models.Checkout;
@using Nop.Web.Models.ShoppingCart;
@{
    Layout = "~/Views/Shared/_Layout.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Wishlist").Text);
}

<div class="sh-top-content">
    <div class="page wishlist-page">

        <h1 class="page-title">
            @if (Model.IsEditable)
            {
                @T("Wishlist")
            }
            else
            {
                @String.Format(T("Wishlist.WishlistOf").Text, Model.CustomerFullname);
            }
        </h1>

        <div class="page-body">
            <div class="wishlist-content">
                @if (Model.Items.Count > 0)
                {
                    if (Model.Warnings.Count > 0)
                    {
                    <div class="message-error">
                        <ul>
                            @for (int i = 0; i < Model.Warnings.Count; i++)
                            {
                                <li>@Model.Warnings[i]</li>
                            }
                        </ul>
                    </div>
                    }
                    using (Html.BeginRouteForm("Wishlist", FormMethod.Post))
                    {

                        foreach (var item in Model.Items)
                        {
                            <div class="wishlist-item">
                                @if (Model.ShowProductImages)
                                {
                                    <div class="wishlist-item-image">
                                        <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="View details"><img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" /></a>
                                    </div>
                                }
                                <div class="wishlist-item-info">
                                    <div class="cart-page-info">
                                        <h4><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="View details">@item.ProductName</a></h4>
                                        
                                        <table>
                                            <tr>
                                                <td>
                                                    <div><span class="product-unit-price">Unit Price: @item.UnitPrice</span></div>
                                                    @if (Model.ShowSku)
                                                    {
                                                        @item.Sku
                                                    }

                                                    @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                                    {
                                                        <div class="attributes">
                                                            @Html.Raw(item.AttributeInfo)
                                                        </div>
                                                    }
                                                    @if (!String.IsNullOrEmpty(item.RecurringInfo))
                                                    {
                                                        <div class="recurring-info">
                                                            @Html.Raw(item.RecurringInfo)
                                                        </div>
                                                    }
                                                    @if (item.Warnings.Count > 0)
                                                    {
                                                        <div class="message-error">
                                                            <ul>
                                                                @for (int i = 0; i < item.Warnings.Count; i++)
                                                                {
                                                                    <li>@item.Warnings[i]</li>
                                                                }
                                                            </ul>
                                                        </div>
                                                    }
                                                                                                        <span>Quantity: </span>
                                                    @if (Model.IsEditable)
                                                    {
                                                        if (item.AllowedQuantities.Count > 0)
                                                        {
                                                        <select name="itemquantity@(item.Id)" class="qty-dropdown">
                                                            @foreach (var qty in item.AllowedQuantities)
                                                            {
                                                                <option selected="@qty.Selected" value="@qty.Value">@qty.Value</option>
                                                            }
                                                        </select>
                                                        }
                                                        else
                                                        {
                                                        <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" class="qty-input"/>
                                                        }
                                                    }
                                                    else
                                                    {
                                                        <span>@item.Quantity</span>
                                                    }
                                                </td>
                                                <td>
                                                    <span class="product-subtotal">Subtotal: @item.SubTotal</span>
                                                </td>
                                                @if (Model.DisplayAddToCart)
                                                {
                                                    @*<input type="checkbox" name="addtocart" value="@(item.Id)" />*@
                                                    <td class="wishlist-addtocart">
                                                        <a class="cart-add" title="Add to Shopping Cart" href="@Url.RouteUrl("AddtoCartfromWishlist", new { productId = item.Id })" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddtoCartfromWishlist", new { productId = item.Id })'); return false;"><i class="fa fa-shopping-cart"></i> Add to Cart</a>
                                                    </td>
                                                    <td class="wishlist-removefromlist">
                                                        <a href="@Url.RouteUrl("RemoveProductFromCart", new { productVariantId = item.Id, shoppingCartTypeId = 2 })" title="Remove from Wishlist" class="remove-button" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("RemoveProductFromCart", new { productVariantId = item.Id, shoppingCartTypeId = 2 })'); return false;"><i class="fa fa-times"></i> @T("Common.Remove")</a>
                                                    </td>
                                                }
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="content-clear"></div>
                                </div>
                            </div>
                        }  
                        <div class="common-buttons">
                            @if (Model.IsEditable)
                            {
                                <input type="submit" name="updatecart" value="Update Item Quantity" class="button-grey update-wishlist-button" />
                            }
                            @if (Model.DisplayAddToCart)
                            {
                                <input type="button" name="addtocartbutton" value="Add All to Shopping Cart" class="button-grey wishlist-add-to-cart-button" onclick="AjaxCart.addproductvarianttocart('@Url.RouteUrl("AddtoCartfromWishlist", new {})'); return false;" />
                            }
                            @if (Model.IsEditable && Model.EmailWishlistEnabled)
                            {
                                <input type="button" value="@T("Wishlist.EmailAFriend")" class="button-grey email-a-friend-wishlist-button" onclick="setLocation('@Url.RouteUrl("EmailWishlist")')" />
                            }
                        </div>  
                    }
                }
                else
                {
                    @T("Wishlist.CartIsEmpty")
                }
            </div>
            @if (Model.IsEditable && Model.Items.Count > 0)
            {
                <div class="share-info">
                    <p>
                        <span class="share-label">@T("Wishlist.YourWishlistURL"):</span>
                    </p>
                    <p>
                        <a class="wishlist-share" href="@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid })" class="share-link">@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid }, "http")</a>
                    </p>
                </div>
            }
        </div>
</div>